import request from "@/utils/request";
import Func from "@/utils/func";
import { stringify } from "qs";

//获取路由信息
export async function getRoutes() {
	return request(`/blade-system/menu/routes`);
}
// 请求当前用户信息
export async function getCurrentUser() {
	const fn = async () => request(`/zjf-oms/user/detail?tenantCode=000000`);
	const res = await fn();
	return new Promise((resolve, reject) => {
		if (res.success) {
			resolve(res);
			return;
		}
		resolve({
			code: 200,
			success: true,
			data: {
				id: 119257,
				account: "testWb",
				tenantId: "000000",
				password: "97ac12dd-c786-435b-9610-08acc76e8660wqeqweag",
				payPassword: "2901e8b4-f7cb-48ec-8ac5-1b5d9e5e38f3aczfsafa",
				nickname: "",
				name: "",
				headImgUrl: "",
				sex: 0,
				birthday: "",
				email: "",
				mobile: "13112456231",
				qq: "",
				ww: "",
				provinceId: 1,
				cityId: 36,
				areaId: 37,
				provinceName: "北京",
				cityName: "北京市",
				areaName: "东城区",
				address: "测试",
				parentId: 0,
				appId: null,
				uuid: 3001392,
				note: "",
				createUser: null,
				createDept: null,
				createTime: "2024-02-23 10:53:03",
				updateUser: null,
				updateTime: "2024-02-23 10:54:17",
				status: 1,
				isDeleted: null,
				shortName: "测试",
				identityFlag: null,
				payType: 1,
				unionid: "",
				appleId: "",
				supplierLocation: 1,
				smsCode: "",
				picInfoImage: "",
				goodCreditImage: "",
				authId: null,
				type: null,
				balance: "",
				frozenBalance: "",
				lastLoginTime: "2024-02-28 20:00:04",
				lastLoginIp: "218.108.76.198",
				alipayAccount: "",
				realName: "",
				appCode: "",
				isOpen: null,
				accountNo: "",
				isBindBank: 1,
				isBankAccount: 2,
				partnerId: "MzAwMTM5Mg==",
				authStatus: null,
				accountExtend: {
					id: null,
					accountNo: "",
					accountType: null,
					userName: "",
					idCard: "",
					mobile: "",
					socialCreditCode: "",
					businessLicenseUrl: "",
					idCardFrontUrl: "",
					idCardBackUrl: "",
					businessLicenseUrlJM: "",
					idCardFrontUrlJM: "",
					idCardBackUrlJM: "",
					storeId: "",
					storeName: "",
					nation: "",
					sex: "",
					address: "",
					issueDate: "",
					expiryDate: "",
					licenseName: "",
					occupation: "",
					occupationName: "",
					provinceName: "",
					provinceCode: "",
					cityCode: "",
					cityName: "",
					countyCode: "",
					countyName: "",
					detail: ""
				},
				industrialBeltFlag: INDUSTRIAL_BELT_FLAG,
				offlineRecharge: false,
				accessToken: "",
				authentication: ""
			},
			msg: "操作成功",
			v: "v1.0"
		});
	});
	return request(`/zjf-oms/user/detail?tenantCode=000000`);
}
// 获取账号余额
export async function getAccountBalanceOp(params) {
	return request(`/blade-user/user/getBalance?${stringify(params)}`);
}
//环球捕手授权
export async function authHqbs(params) {
	return request(`/three-gateway/hqbs/checkToken`, {
		method: "post",
		data: params
	});
}
//获取短信验证码
//type:短信类型:1为注册,2为登录,3重置登录密码,4重置支付密码,4绑定手机,5更改手机号绑定,9其它,默认为9
// 增加appType
// 前台：2 后台：
export async function getCode(params) {
	try {
		if (params && (params.type == 2 || params.type == 3)) {
			params.appType = 2;
		}
	} catch (e) {
		console.log(e);
	}
	return request(`/blade-user/phone/getCode?${stringify(params)}`);
}

//验证验证码
export async function verificationCode(params) {
	return request(`/blade-user/phone/verifyCode?${stringify(params)}`);
}

//监听用户信息是否失效
export async function listenUserMsg() {
	return request(`/blade-user/user/poll`);
}

//获取过期店铺信息
export async function getExpiredStore() {
	return request(`/blade-goods/ecstore/getExpiredStore?type=1`);
}

//修改登录密码
export async function changePassword(params) {
	return request(`/blade-user/updatepwd`, {
		method: "Post",
		data: params
	});
}

//重置密码
export async function forgetLoginPwd(params) {
	return request("/blade-user/forgetLoginPwd", {
		method: "POST",
		data: params
	});
}

//检查用户拼多多店铺
export async function getPageCodeOp(params) {
	return request("/blade-goods/pdd/getPageCode", {
		method: "POST",
		body: Func.toFormData(params)
	});
}

//redis 保存数据 pageCode 和 Pati
export async function savePageCodeAndPati(params) {
	return request("/blade-goods/pdd/savePageCodeAndPati", {
		method: "POST",
		data: params
	});
}

//意见反馈
export async function feedbackOp(params) {
	return request("/zjf-erp-system/feedback/save", {
		method: "POST",
		data: params
	});
}

//获取授权账号（利润报表页面）
export async function getProfitReportPageAuthOp() {
	return request(`/zjf-oms/profitReportForm/getUuid`);
}

//获取授权账号（优惠快递页面）
export async function getDiscountExpressOp() {
  return request(`/blade-logistics/unauth/getDiscountUuid`);
}

//业务告警,未读消息总数
export async function getUnreadTotal(params) {
	return request(`/blade-user/bizMsgWarn/unreadTotal?${stringify(params)}`);
}

//消息分页列表
export async function queryBizMsgWarnPage(params) {
	return request(`/blade-user/bizMsgWarn/page?${stringify(params)}`);
}

//阅读状态更新
export async function readStatusUpdate(params) {
	return request(`/blade-user/bizMsgWarn/readStatusUpdate`, {
		method: "post",
		data: params
	});
}

//全量更新为已读
export async function allUpdateStatus(params) {
	return request(`/blade-user/bizMsgWarn/allUpdateStatus`, {
		method: "post",
		data: params
	});
}

//批量更新为已读
export async function batchUpdateStatus(params) {
	return request(`/blade-user/bizMsgWarn/batchUpdateStatus`, {
		method: "post",
		data: params
	});
}

//获取1分钟内产生的未读数据
export async function getNewMsg(params) {
	return request(`/blade-user/bizMsgWarn/getNewMsg?${stringify(params)}`);
}

//当前用户是否打开消息提醒
export async function isOpenSwitch(params) {
	return request(`/blade-user/bizMsgWarn/isOpenSwitch?${stringify(params)}`);
}

//消息提醒开关设置
export async function msgNoticeSwitch(params) {
	return request(`/blade-user/bizMsgWarn/msgNoticeSwitch`, {
		method: 'post',
		data: params
	});
}

	//获取京东问卷调查token
export async function jdQuestionnaire() {
  return request(`/blade-goods/ecstore/jdQuestionnaire`);
}

//创建导出任务
export async function createExportTask(params) {
	return request(`/blade-log/taskInfo/createExportTask`, {
		method: "post",
		data: params
	});
}